package org.core.tliaswebmanagement.mapper;

import org.apache.ibatis.annotations.*;
import org.core.tliaswebmanagement.pojo.Student;
import org.core.tliaswebmanagement.pojo.StudentQueryParam;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    List<Student> list(StudentQueryParam param);

    @Insert("insert into student(name,no,gender,phone,degree,clazz_id,id_card,is_college,address,graduation_date,update_time)"+
            "values(#{name},#{no},#{gender},#{phone},#{degree},#{clazzId},#{idCard},#{isCollege},#{address},#{graduationDate},#{updateTime})")
    void insert(Student student);

    void deleteByIds(@Param("ids") List<Integer> ids);

    @Select("select * from student where id=#{id}")
    Student getById(Integer id);

    void update(Student student);

    @Update("update student set violation_score=student.violation_score+#{score},violation_count=violation_count+1 where id=#{id}")
    void updateViolationById(@Param("id")Integer id,@Param("score") Integer score);

    List<Map<String, Object>> countStudentDegreeData();

    List<Map<String, Object>> getStudentCountData();
}
